Hello, I have one CSV file where column start with normal character. but when I run a script and print value that time special character ' " ' (double quote) is also printed at the starting of string. But its not visible in .csv file For eg: line present in csv file is: B12-Constant ; OK ; True when i print B12-Constant by running dxl script, the output is "B12-Constant i want to remove this double quote from csv file. Can you please suggest me something. Thank you in advance Regards, Hemlata HemlataS - Wed Jun 19 05:09:26 EDT 2013 |
Re: Regarding hidden special symbol present in .csv file Use notepad.exe to open the CSV file. I believe you will see a barrage of double-quote characters. (Advise: find your "Send-To" folder and add "notepad.exe" to it. Then you can right click on a file and Send-to Notepad. That is easier than opening Notepad and browsing for the file). I don't recall all the rules for "CSV" file format as interpreted my MS-Excel, but the individual cells can and often (or usually or always) are surrounded by double quotes. Anyway, if you are using DXL to open the CSV and parse it; you need to write some clever functions to accurately read and delimit the cells. It is non-trivial. A "cell" may or may not start with a double-quote. If it does, then the cell ends at the next double quote that is not preceded by an odd number of backslash characters "\". If the corresponding end-double-quote is not followed by a comma then either Louie made a mistake or the CSV file is in improper format. If a cell does NOT start with a double quote then the cell ends at the next comma that is not preceded by an odd number of backslash characters. Double-quotes and commas that are supposed to be part of the cell contents are preceded by an odd number of backslash characters, 99.99% of the time just one. -Louie |
Re: Regarding hidden special symbol present in .csv file The comma character is a reserved character in CSV files for what I hope is obvious reasons. So quote characters are used in CSV files when the text within a field also includes a comma and could be confused as being the reserved comma delimiter for the next field. Quote characters indicate the start and end of a block of text where any comma characters can be ignored. So the the following text: CSV is a common, relatively simple file format Would look like this in a CSV file: "CSV is a common, relatively simple file format" But now the quote character is also a reserved character in CSV files. If the text within a field contains quoted text and a comma, then it starts to get ugly as double quotes are now needed to prevent confusion as to what each quote character means. So the the following text: The man said "You're weird, but I like you" Would look like this in a CSV file: "The man said ""You're weird, but I like you""" Some applications that can save\export data to a CSV file format sometimes play it safe or are just lazy and enclose all fields with quote characters anyway. The CSV standard is bit vague about forward and backward slash character so any text containing these such as date formats should be enclosed with quotes, and then there is the problem of forcing some fields in a CSV to be imported as text only data into sophisticated tools like MS Excel but I won't go there as it gets complicated.
Paul Miller |
Re: Regarding hidden special symbol present in .csv file PRM - Wed Jun 19 18:19:44 EDT 2013 The comma character is a reserved character in CSV files for what I hope is obvious reasons. So quote characters are used in CSV files when the text within a field also includes a comma and could be confused as being the reserved comma delimiter for the next field. Quote characters indicate the start and end of a block of text where any comma characters can be ignored. So the the following text: CSV is a common, relatively simple file format Would look like this in a CSV file: "CSV is a common, relatively simple file format" But now the quote character is also a reserved character in CSV files. If the text within a field contains quoted text and a comma, then it starts to get ugly as double quotes are now needed to prevent confusion as to what each quote character means. So the the following text: The man said "You're weird, but I like you" Would look like this in a CSV file: "The man said ""You're weird, but I like you""" Some applications that can save\export data to a CSV file format sometimes play it safe or are just lazy and enclose all fields with quote characters anyway. The CSV standard is bit vague about forward and backward slash character so any text containing these such as date formats should be enclosed with quotes, and then there is the problem of forcing some fields in a CSV to be imported as text only data into sophisticated tools like MS Excel but I won't go there as it gets complicated.
Paul Miller Thank you very much for the reply. Regards, Hemlata |
Re: Regarding hidden special symbol present in .csv file llandale - Wed Jun 19 12:34:14 EDT 2013 Use notepad.exe to open the CSV file. I believe you will see a barrage of double-quote characters. (Advise: find your "Send-To" folder and add "notepad.exe" to it. Then you can right click on a file and Send-to Notepad. That is easier than opening Notepad and browsing for the file). I don't recall all the rules for "CSV" file format as interpreted my MS-Excel, but the individual cells can and often (or usually or always) are surrounded by double quotes. Anyway, if you are using DXL to open the CSV and parse it; you need to write some clever functions to accurately read and delimit the cells. It is non-trivial. A "cell" may or may not start with a double-quote. If it does, then the cell ends at the next double quote that is not preceded by an odd number of backslash characters "\". If the corresponding end-double-quote is not followed by a comma then either Louie made a mistake or the CSV file is in improper format. If a cell does NOT start with a double quote then the cell ends at the next comma that is not preceded by an odd number of backslash characters. Double-quotes and commas that are supposed to be part of the cell contents are preceded by an odd number of backslash characters, 99.99% of the time just one. -Louie Thank you very much Louie for the reply. Regards, Hemlata |